// src/api/brand.js
import genericApi from "@/util/genericApi.js";

const SERVICE_NAME = "member-api"; // 品牌微服务名称
const BASE_URL = "/members";

async function getBrands(params) {
    return genericApi.get(SERVICE_NAME, BASE_URL+"/list", params);
}

async function getBrandById(id) {
    return genericApi.get(SERVICE_NAME, `${BASE_URL}/${id}`);
}

async function createBrand(data) {
    return genericApi.post(SERVICE_NAME, BASE_URL+"/register", data);
}

async function updateBrand(id, data) {
    return genericApi.put(SERVICE_NAME, BASE_URL, data);
}

async function deleteBrand(ids) {
    const idsArray = Array.isArray(ids) ? ids : [ids];
    return genericApi.delete(SERVICE_NAME, `${BASE_URL}/delete`, {}, idsArray);
}

async function uploadPortrait(formData) {
    return genericApi.post(SERVICE_NAME, BASE_URL+"/upload", formData);
}

export { getBrands, getBrandById, createBrand, updateBrand, deleteBrand,uploadPortrait }
